1. Field of the Invention
The present invention relates to a method and an apparatus for packet transmission, which are provided to transmit packets onto a packet network such as the Internet or the like, and a bandwidth guaranteeing method.
2. Description of the Related Art
In a terminal device on a packet network such as the Internet, to control the amount of data to be transmitted per unit time, it is necessary to limit the number of packets to be transmitted per unit time at a network interface. For example, referring to FIG. 1, there is shown a conventional process for limiting the amount of data transfer per unit time, i.e., a bandwidth to be used. This process is carried out as follows: by using a leaky bucket algorithm or the like, packets PK received from an application are temporarily stored in a buffer, i.e., in the queue of a driver, at the network interface and, then, the packets are dequeued from the queue at fixed intervals, and are transmitted one by one at each fixed interval.
In this conventional case, if a packet size is variable in length, it is impossible to accurately control the amount of data transfer while the interval of packet transmission is kept fixed. Accordingly, as shown in FIG. 2, the interval of transmission must be changed according to the size of each packet. In addition, even if a packet size is fixed in length, the interval of packet transmission must be changed when there is a change in the amount of data transfer per unit time. Thus, when it was necessary to dynamically change the interval of packet transmission, processing was carried out according to a process like that shown in the flowchart of FIG. 3.
Specifically, in the process shown in the flowchart of FIG. 3, first, next packet transmission time tn is initialized by 0 (step S51).
Then, a packet is dequeued from a queue (step S52). A packet size is divided by a current transfer rate to calculate time tx necessary for packet transmission (step S53).
Then, comparison is made between current time t and the packet transmission time tn to determine whether t<tn is established or not (step S54). When the current time t reaches the time tn for packet transmission, the packet is transmitted (step S55).
Then, tn=t+tx, that is, next packet transmission time tn is calculated by adding the time tx necessary for packet transmission to the current time t (step S56).
Subsequently, the process returns to step S52 to execute processing for a next packet. By repeating the foregoing operations from step S52 to step S56, packets are sequentially transmitted.
In the conventional process described above with reference to the flowchart of FIG. 3, if the calculation of the interval of packet transmission is executed immediately before transmission, there is a possibility that the time of calculation will be longer than the calculated interval of packet transmission. This problem occurs in particular when the amount of data transfer per unit time is large, or when the time of calculation for a leaky bucket is slow. In other words, for example, in the examples shown in FIGS. 2 and 3, the state of t being larger than tn may occur during the calculation of tx with the consequence of incorrect packet transmission or other problems. Therefore, it may even be impossible to control the amount of data to be transmitted per unit time.
When the number of flows through the network interface is single, there will be no problems if a packet flow rate is controlled by the network interface. On the other hand, when a plurality of flows share one network interface, not only a bandwidth to be used but also other network resources such as a transmission buffer will also be shared by the plurality of flows. In such a case, to prevent interference among the flows, the method of Fair Queueing for dividing queues among the flows like that shown in FIG. 4 is used. A flow is specified based on an identifier of one kind or another, and each flow can use exclusive queue, e.g., an identifier A to a queue Qa, an identifier B to a queue Qb, an identifier C to a queue Qc, and so on, up to an identifier Z to a queue Qz. For example, in a network using a TCP/IP as a communication protocol, each packet is provided with a packet header like that shown in FIG. 5. Accordingly, a flow identifier can be formed by combining the IP addresses, the port numbers of both transmitting/receiving sides, a protocol number, and parts or all of other fields. The packets enqueued according to the identifiers are sequentially dequeued one by one by Round Robin, and transmitted into the network. In the example of FIG. 4, the chances of packet transmission are given to the respective queues in order, e.g., QaRQbRQcR , , , RQzRQaR (the process returns to the first queue Qa after the last queue Qz is reached). If there is a packet contained in the queue that has been given the transmission chance, then the packet is transmitted to the network.
If there is bandwidth specification for a plurality of flows, a bandwidth guarantee per flow unit can be realized by combining the foregoing two methods to control a flow rate by a leaky bucket at the outlet of each queue as shown in FIG. 6.
However, there is no clear division between a scheduling module for deciding the order of transmitting packets, i.e., the queue of a next packet to be transmitted, and a shaping module for controlling a packet flow rate so as to keep the data transfer amount of each flow within a reserved bandwidth. Consequently, the amount of information to be managed by a queue unit is large, making management work complex. In addition, to change only one of the scheduling and shaping methods, because of unclear division thereof, changing work cannot be easily carried out.
In addition, the control of a packet flow rate using a leaky bucket or the like is carried out based on the granularity of a kernel clock as a minimum unit for counting time within a kernel. Thus, a considerable reduction occurs in accuracy for the data link of a broad bandwidth.
Furthermore, as shown in FIG. 7, when a plurality of flows, resource reservation having been made therefor, are transmitted from a plurality of transmission terminals, or passed through a certain network intermediate node, network resources at this node are shared by the plurality of flows. Accordingly, at the network intermediate node, the information of each flow must be held for flow identification, and flow identification must be carried out by referring to the information each time a packet is received. The packet that has been subjected to flow identification is enqueued. In addition, scheduling, a queue memory management, and so on, must be carried out. The processing work of this kind is increased in proportion to an increase in the number of target flows. Consequently, in a large-scale network, such processing costs will be extremely large.